<template>
    <div class="mv-box">
        <ul
            class="mv-list"
            v-if="mvs.length > 0"
        >
            <li
                v-for="item of mvs"
                :key="item.id"
                :class="item.isLive ? 'live' : ''"
            >
                <div class="cover">
                    <div class="image">
                        <el-image
                            :src="item.image + '?param=325y197'"
                            lazy
                        >
                            <div
                                slot="placeholder"
                                class="image-slot "
                            >
                                <i class="iconfont niceicon-3"></i>
                            </div>
                            <div
                                slot="error"
                                class="image-slot "
                            >
                                <i class="el-icon-picture-outline"></i>
                            </div>
                        </el-image>
                    </div>
                    <div class="count flex-between">
                        <i class="el-icon-caret-right"></i>
                        <span>{{ utils.tranNumber(item.playCount, 0) }}</span>
                    </div>
                    <div class="play-btn">
                        <button
                            class="play "
                            v-if="!item.isLive"
                            @click="toDetail(item.id, item.type)"
                        >
                            <i class="iconfont nicebofang1"></i>
                        </button>
                        <button
                            class="play"
                            v-else
                            @click="toLive(item.id)"
                        >
                            <i class="iconfont nicebofang1"></i>
                        </button>
                    </div>
                    <div class="foot">
                        <p>{{ item.nickName }}</p>
                        <p>{{ item.duration }}</p>
                    </div>
                </div>
                <div class="info">
                    <h2 class="title ellipsis">{{ item.name }}</h2>
                </div>
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    data() {
        return {

        }
    },
    props: {
        mvs: {
            type: Array
        },
        type: {
            type: String
        }
    },
    created() {

    },
    methods: {
        // 视频详情
        toDetail(id) {
            if (typeof id == 'number' || id.length < 10) {
                this.$router.push({
                    name: 'mvDetail',
                    query: {
                        id
                    }
                })
            } else {
                this.$router.push({
                    name: 'videoDetail',
                    query: {
                        id
                    }
                })
            }
        },
    },
}
</script>

<style lang="less" scoped>
.mv-box {
    padding: 15px 0;
    .mv-list {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        margin: 0 -15px;
        li {
            padding: 0 15px 10px;
            flex: 0 0 25%;
            .cover {
                width: 300px;
                height: 180px;
                position: relative;
                z-index: 2;
                background-color: #000;
                .image {
                    .image-slot {
                        i {
                            line-height: 180px;
                        }
                    }
                }
                .count {
                    position: absolute;
                    right: 16px;
                    top: 6px;
                    height: 20px;
                    line-height: 20px;
                    padding: 5px 9px;
                    background: #001720;
                    color: #fff;
                    font-size: 12px;
                    font-weight: 700;
                    border-radius: 3px;
                }
                .play-btn {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    .play {
                        display: none;
                        width: 32px;
                        height: 32px;
                        border: none;
                        border-radius: 50%;
                        color: #fff;
                        cursor: pointer;
                        background-color: #fa2800;
                        i {
                            font-size: 12px;
                        }
                    }
                }
                &:hover {
                    .play {
                        display: block;
                    }
                }
                .foot {
                    position: absolute;
                    bottom: -2px;
                    width: 100%;
                    height: 35px;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    background: rgba(0, 0, 0, 0.6);
                    color: #fff;
                    padding: 0 10px;
                }
            }
            .info {
                margin-top: 15px;
                .title {
                    font-size: 14px;
                    font-weight: normal;
                }
            }
        }
    }
}
</style>